﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HRdex_Final.Calendar
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Calendar1_DayRender1(object sender, DayRenderEventArgs e)
        {
            DataClassesDataContext db = new DataClassesDataContext();
            var activities = from a in db.catEvents where a.date.Date == e.Day.Date select a;
            foreach (catEvent a in activities)
            {
                //for tooltip
                e.Cell.ToolTip = "Click to see details of this event";
                string url = e.SelectUrl;
                e.Cell.Controls.Clear();
                HyperLink hlink = new HyperLink();
                hlink.Text = e.Day.Date.Day.ToString();
                hlink.ToolTip = "Click to see details of this event";
                e.Cell.Controls.Add(hlink);

                HyperLink link = new HyperLink();
                link.Text = a.Title;
                link.CssClass = "activity";
                link.NavigateUrl = Page.ClientScript.GetPostBackClientHyperlink(CalendarLinkButton, a.EventID.ToString(), true);
                e.Cell.Controls.Add(link);
            }
        }

        protected void CalendarLinkButton_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request.Form["__EVENTARGUMENT"]);

            DataClassesDataContext db = new DataClassesDataContext();
            var activity = (from a in db.catEvents where a.EventID == id select a).Single();

            ResultsLabel.Text = String.Format("{0}", activity.Description);
        }
    }
}